﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace Studio
{
	// Token: 0x0200052B RID: 1323
	public class SkyList : MonoBehaviour
	{
		// Token: 0x060021AE RID: 8622 RVA: 0x000CD6E8 File Offset: 0x000CB8E8
		public void UpdateInfo()
		{
			if (!this.isInit)
			{
				return;
			}
			foreach (KeyValuePair<int, GameSceneNode> keyValuePair in this.dicNode)
			{
				keyValuePair.Value.select = false;
			}
			GameSceneNode gameSceneNode = null;
			if (this.dicNode.TryGetValue(Singleton<Studio>.Instance.sceneInfo.skybox, out gameSceneNode))
			{
				gameSceneNode.select = true;
				this.select = Singleton<Studio>.Instance.sceneInfo.skybox;
			}
			else if (this.dicNode.TryGetValue(-1, out gameSceneNode))
			{
				gameSceneNode.select = true;
				this.select = -1;
			}
		}

		// Token: 0x060021AF RID: 8623 RVA: 0x000CD7BC File Offset: 0x000CB9BC
		public void OnClick(int _no)
		{
			Singleton<Studio>.Instance.AddSkybox(_no, true);
			GameSceneNode gameSceneNode = null;
			if (this.dicNode.TryGetValue(this.select, out gameSceneNode))
			{
				gameSceneNode.select = false;
			}
			if (this.dicNode.TryGetValue(_no, out gameSceneNode))
			{
				gameSceneNode.select = true;
			}
			this.select = _no;
		}

		// Token: 0x060021B0 RID: 8624 RVA: 0x000CD818 File Offset: 0x000CBA18
		private void InitList()
		{
			this.AddNode(-1, "なし");
			foreach (KeyValuePair<int, Info.LoadCommonInfo> keyValuePair in Singleton<Info>.Instance.dicSkyLoadInfo)
			{
				this.AddNode(keyValuePair.Key, keyValuePair.Value.name);
			}
			GameSceneNode gameSceneNode = null;
			if (this.dicNode.TryGetValue(Singleton<Studio>.Instance.sceneInfo.skybox, out gameSceneNode))
			{
				gameSceneNode.select = true;
			}
			this.isInit = true;
		}

		// Token: 0x060021B1 RID: 8625 RVA: 0x000CD8C8 File Offset: 0x000CBAC8
		private void AddNode(int _key, string _name)
		{
			GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.objectNode);
			gameObject.transform.SetParent(this.transformRoot, false);
			if (!gameObject.activeSelf)
			{
				gameObject.SetActive(true);
			}
			GameSceneNode component = gameObject.GetComponent<GameSceneNode>();
			int key = _key;
			component.AddActionToButton(delegate
			{
				this.OnClick(key);
			});
			component.text = _name;
			this.dicNode.Add(key, component);
		}

		// Token: 0x060021B2 RID: 8626 RVA: 0x000CD94C File Offset: 0x000CBB4C
		private void Awake()
		{
			this.isInit = false;
			this.InitList();
		}

		// Token: 0x04002313 RID: 8979
		[SerializeField]
		private GameObject objectNode;

		// Token: 0x04002314 RID: 8980
		[SerializeField]
		private Transform transformRoot;

		// Token: 0x04002315 RID: 8981
		private int select = -1;

		// Token: 0x04002316 RID: 8982
		private Dictionary<int, GameSceneNode> dicNode = new Dictionary<int, GameSceneNode>();

		// Token: 0x04002317 RID: 8983
		private bool isInit;
	}
}
